package com.csun.cmny.provider.service.impl;

import com.csun.cmny.base.dto.LoginAuthDto;
import com.csun.cmny.core.support.BaseService;
import com.csun.cmny.provider.mapper.OpcAppClockMapper;
import com.csun.cmny.provider.model.domain.OpcAppClock;
import com.csun.cmny.provider.model.dto.AppClockQueryDto;
import com.csun.cmny.provider.service.OpcAppClockService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Auther: chisj chisj@foxmal.com
 * @Date: 2019-10-28 20:57
 * @Description:
 */
@Service
@Transactional
public class OpcAppClockServiceImpl extends BaseService<OpcAppClock> implements OpcAppClockService {

    @Resource
    private OpcAppClockMapper opcAppClockMapper;

    /**
     * save opc app clock
     *
     * @param opcAppClock  the opc app clock
     * @param loginAuthDto the login auth dto
     * @return the int
     */
    @Override
    public Integer save(OpcAppClock opcAppClock, LoginAuthDto loginAuthDto) {

        opcAppClock.setUpdateInfo(loginAuthDto);
        opcAppClock.setUserId(loginAuthDto.getUserId());

        if (opcAppClock.isNew()) {
            return opcAppClockMapper.insertSelective(opcAppClock);
        } else {
            return opcAppClockMapper.updateByPrimaryKeySelective(opcAppClock);
        }
    }

    /**
     * query opc app clock query list with page
     *
     * @param appClockQueryDto the app clock query dto
     *
     * @return the list.
     */
    @Override
    public List<OpcAppClock> queryListWithPage(AppClockQueryDto appClockQueryDto) {

        return opcAppClockMapper.queryListWithPage(appClockQueryDto);
    }
}
